package com.easyaop.asm.pointcut;

import com.easyaop.api.pointcut.MethodObject;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.MethodNode;

import java.util.List;
import java.util.stream.Collectors;

public class ForAsm implements MethodObject {

    private MethodNode methodNode;
    private String name;

    public ForAsm(String name,MethodNode methodNode) {
        this.methodNode = methodNode;
        this.name=name.replaceAll("/", ".");
    }

    @Override
    public String getClassName() {
        return name;
    }

    @Override
    public String getName() {
        return methodNode.name;
    }

    @Override
    public String getDescriptor() {
        return methodNode.desc;
    }

    @Override
    public List<String> getAnnotations() {
        return methodNode.visibleAnnotations.stream().map(a -> a.desc).map(Type::getType)
                .map(Type::getClassName)
                .collect(Collectors.toList());
//            return null;
    }
}

